﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SmartMathLibrary.Optimization
{
    /// <summary>
    /// This class represents an abstract layer for multidimensional optimization.
    /// </summary>
    [Serializable]
    public abstract class AbstractMultidimensionalOptimizer
    {
        /// <summary>
        /// The base function to optimization.
        /// </summary>
        private IHardMultivariateRealFunction function;

        /// <summary>
        /// Initializes a new instance of the <see cref="AbstractMultidimensionalOptimizer"/> class.
        /// </summary>
        /// <param name="function">The base function to optimize.</param>
        protected AbstractMultidimensionalOptimizer(IHardMultivariateRealFunction function)
        {
            if (function == (HardMultivariateRealFunction) null)
            {
                throw new ArgumentNullException("function");
            }

            this.function = function;
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="AbstractMultidimensionalOptimizer"/> class.
        /// </summary>
        /// <param name="function">The base function to optimize.</param>
        protected AbstractMultidimensionalOptimizer(HardMultivariateRealFunction function)
        {
            this.function = function;
        }

        /// <summary>
        /// Gets or sets the base function to optimize.
        /// </summary>
        /// <value>The base function to optimize.</value>
        public IHardMultivariateRealFunction Function
        {
            get { return function; }
            set { function = value; }
        }
    }
}